import _pickle as cPickle
import matplotlib.pyplot as plt

fr = open('Car_pr.pkl','rb')
inf = cPickle.load(fr)
fr.close()
 
x=inf['rec']
y=inf['prec']
plt.figure()
plt.xlabel('recall')
plt.ylabel('precision')
plt.title('PR cruve of Car')
plt.plot(x,y)
plt.show()
#plt.savefig("pr-car.png")

ap_car =  inf['ap']
print('AP of Car:', ap_car)

###############

fr = open('Pedestrian_pr.pkl','rb')
inf = cPickle.load(fr)
fr.close()
 
x=inf['rec']
y=inf['prec']
plt.figure()
plt.xlabel('recall')
plt.ylabel('precision')
plt.title('PR cruve of Pedestrian')
plt.plot(x,y)
plt.show()
#plt.savefig("pr-pedestrian.png")

ap_pedestrian =  inf['ap']
print('AP of Pedestrian:', ap_pedestrian)

################

fr = open('Cyclist_pr.pkl','rb')
inf = cPickle.load(fr)
fr.close()
 
x=inf['rec']
y=inf['prec']
plt.figure()
plt.xlabel('recall')
plt.ylabel('precision')
plt.title('PR cruve of Cyclist')
plt.plot(x,y)
plt.show()
#plt.savefig("pr-cyclist.png")

ap_cyclist =  inf['ap']
print('AP of Cyclist:', ap_cyclist)

mAP = (ap_car + ap_pedestrian + ap_cyclist) / 3
print('mAP:', mAP)

